import robot from 'robotjs';

// 鼠标移动
robot.setMouseDelay(2);
const twoPI = Math.PI * 2.0;
const screenSize = robot.getScreenSize();
const height = (screenSize.height / 2) - 10;
const width = screenSize.width;

for (let x = 0; x < width; x++) {
    const y = height * Math.sin((twoPI * x) / width) + height;
    robot.moveMouse(x, y);
}

// 键盘输入
// Type "Hello World".
robot.typeString("Hello World");

// Press enter.
robot.keyTap("enter");

// 屏幕颜色
const mouse = robot.getMousePos();
const hex = robot.getPixelColor(mouse.x, mouse.y);
console.log("#" + hex + " at x:" + mouse.x + " y:" + mouse.y);